/*
 * @Author: your name
 * @Date: 2021-01-15 10:33:58
 * @LastEditTime: 2021-01-15 10:43:09
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \carlist\src\store\action\detail.js
 */
import api from "../../api"

import { GET_INFO_AND,GET_IMG_LIST,GET_YEAR_COLOR,GET_CATEGORY_LIST } from "../actionType";

export const getInfoAnd  = (SerialID)=>{
    return (dispatch)=>{
        api.getInfoAnd({
            SerialID
        }).then(res=>{
            dispatch({
                type:GET_INFO_AND,
                data:res.data.data
            })
        })
    }
}

export const getImageList=(SerialID,CarId,ColorID)=>{
    return (dispatch)=>{
        api.getImageList({SerialID,CarId,ColorID}).then(res=>{
            dispatch({
                type:GET_IMG_LIST,
                data:res.data.data
            })
        })
    }
}

export const getYearColor=(SerialID)=>{
    return (dispatch)=>{
        api.getYearColor({SerialID}).then(res=>{
            console.log(res.data.data);
            dispatch({
                type:GET_YEAR_COLOR,
                data:res.data.data
            })
        })
    }
}

export const getCategoryList=(SerialID,ImageID,Page,PageSize)=>{
      return async (dispatch)=>{
          let res=await api.getCategoryList({SerialID,ImageID,Page,PageSize})
          dispatch({
              type:GET_CATEGORY_LIST,
              data:res.data.data
          })
      }
}